import { parseHtmlToAst } from "./astParser";
import { generate } from "./generate";

function compileToRenderFunction(html) {
  const ast = parseHtmlToAst(html), // 生成 AST 树
        code = generate(ast), // render 函数返回出来的字符串
        render = new Function(`
          with(this) { return ${code} }
        `);
  // console.log(ast);
  // console.log(code);
  // console.log(render);
  return render;
}

export {
  compileToRenderFunction
}
